/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.creational.factorymethod;

import com.behavioral.command.Server;
import com.behavioral.command.ServerFTP;
import com.behavioral.command.ServerWeb;
import com.behavioral.command.SeverISMTP;
import com.structural.facade.EnumServer;

import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

/**
 *
 * @author jmg
 */
public class ConcreteFactory<E,T> implements Factory<E,T>{

    private String confFile;

    public ConcreteFactory(String confFile) {
        this.confFile = confFile;
    }
    
    @Override
    public E createObject(T t) throws ClassNotFoundException,InstantiationException,IllegalAccessException{
        ResourceBundle rb = ResourceBundle.getBundle(confFile); 
        String stringClazz = rb.getString(t.toString());
        Class clazz = Class.forName(stringClazz);
        Object o = clazz.newInstance();
        return (E) o;
    }
    
}
